﻿load('nashorn:mozilla_compat.js');
importPackage(java.lang);
importPackage(Packages.client);
importPackage(Packages.client.inventory);
importPackage(Packages.constants);
importPackage(Packages.server);
importPackage(Packages.tools);
var 心 = "#fUI/GuildMark.img/Mark/Etc/00009001/14#";
var JD = "#fUI/Basic/BtHide3/mouseOver/0#";
var seljl = 0;
//累充值，【物品，数量】
var itemlist = [
	[100, [2028061, 10], 
                        [2046222, 10], 
                        [2046313, 10], 
                        [2049300, 10], 
                        [2340000, 10], 
                        [2049005, 10], 
                        [2049116, 10], 
                        [2049124, 10], 
                        [2049006, 10], 
                        [4002003, 50]
],
	[300, [2028061, 20], 
                        [2046222, 20], 
                        [2046313, 20], 
                        [2049300, 20], 
                        [2340000, 20], 
                        [2049005, 20], 
                        [2049116, 20], 
                        [2049124, 20], 
                        [2049006, 20], 
                        [4002003, 100]
],
	[500, [2028061, 50], 
                        [2046010, 5], 
                        [2046011, 5], 
                        [2046110, 5], 
                        [2046111, 5], 
                        [2049130, 5], 
                        [2049131, 5], 
                        [2049407, 5], 
                        [2049006, 5], 
                        [4002003, 100], 
                        [5062001, 100], 
                        [4011005, 120], 
                        [4021001, 120]
],
              [1000, [2028061, 300], 
                        [2046010, 5], 
                        [2046011, 5], 
                        [2046110, 5], 
                        [2046111, 5], 
                        [2049130, 10], 
                        [2049131, 10], 
                        [2049132, 10], 
                        [2049006, 10], 
                        [4002003, 100], 
                        [5062001, 100], 
                        [4011001, 120], 
                        [4021005, 120],
                        [4002001, 100],
                        [4031559, 100],
                        [4002002, 300],
                        [4001465, 300],
                        [4001326, 1],
                        [4001328, 1],
                        [4001331, 1],
],
              [2000, [2028061, 500], 
                        [2049130, 10], 
                        [2049131, 10], 
                        [2049132, 10], 
                        [4002003, 200], 
                        [5062001, 200], 
                        [4011000, 120], 
                        [4011003, 120],
                        [4005002, 120],
                        [4011002, 120],
                        [4021003, 120],
                        [4002001, 100],
                        [4031559, 100],
                        [4002002, 300],
                        [4001465, 300],
                        [4001326, 1],
                        [4001328, 1],
                        [4001331, 1],
                        [1142742, 1]
],
              [5000, [2028061, 1000], 
                        [2049130, 30], 
                        [2049131, 30], 
                        [2049132, 30], 
                        [4002003, 300], 
                        [5062001, 300], 
                        [4011006, 120], 
                        [4021006, 120],
                        [4021002, 120],
                        [4021007, 120],
                        [4005000, 120],
                        [4021000, 120],
                        [4005004, 120],
                        [4021008, 120],
                        [4005001, 120],
                        [4005003, 120],
                        [4011008, 120],
                        [4002001, 300],
                        [4031559, 300],
                        [4002002, 500],
                        [4001465, 500],
                        [4001326, 1],
                        [4001328, 1],
                        [4001331, 1],
                        [1122362, 1],
                        [1122361, 1],
                        [1122364, 1],
                        [1122363, 1],
                        [1122365, 1],
                        [1142796, 1]
],
              [8000, [2028061, 1000], 
                        [2049130, 30], 
                        [2049131, 30], 
                        [2049132, 30], 
                        [4002003, 500], 
                        [4002001, 500],
                        [4031559, 500],
                        [4002002, 1000],
                        [4001465, 1000],
                        [4001326, 3],
                        [4001328, 3],
                        [4001331, 3],
                        [1152124, 1],
                        [1132215, 1],
                        [1122371, 1],
                        [1122372, 1],
                        [1122373, 1],
                        [1122374, 1],
                        [1122375, 1]
],
            [10000, [2049132, 30], 
                        [4002003, 500], 
                        [4002002, 10000],
                        [1012414, 1],
                        [1022195, 1],
                        [1032201, 1],
                        [1113056, 1],
                        [1122259, 1],
                        [4011004, 80],
                        [4011009, 80],
                        [4021004, 80],
                        [4011005, 80],
                        [4021001, 80],
                        [4011001, 80],
                        [4021005, 80],
                        [4011000, 80],
                        [4011003, 80],
                        [4005002, 80],
                        [4011002, 80],
                        [4021003, 80],
                        [4011006, 80],
                        [4021006, 80],
                        [4021002, 80],
                        [4021007, 80],
                        [4005000, 80],
                        [4021000, 80],
                        [4005004, 80],
                        [4021008, 80],
                        [4005001, 80],
                        [4005003, 80],
                        [4011008, 80]]
]
var status = 0;
function start() {
	status = -1;
	action(1, 0, 0);
}

function action(mode, type, selection) {
	if (mode == -1) {
		cm.dispose();
	} else {
		if (status >= 0 && mode == 0) {
			cm.dispose();
			return;
		}
		if (mode == 1)
			status++;
		else
			status--;
		if (!cm.canHoldSlots(2)) {
			cm.sendOk("请保证 #b背包#k 至少有2个位置。");
			cm.dispose();
			return;
		}
		if (cm.getBossRank("点券积分", 2) > 0) {
			var 充值积分 = cm.getBossRank("点券积分", 2);
		} else {
			var 充值积分 = 0;
		}
		if (status == 0) {
			var txt = ""
			txt += "#e#r\t" + 心 + "\t" + 心 + "  欢迎来到eV.095冒险岛  " + 心 + "\t" + 心 + "\t#k#n\r\n\r\n"
			txt += "#b=================#e [累计充值奖励] #n==================#k\r\n\\r\n";
			txt += "\t#d感谢您对枫叶冒险岛的支持，所有充值礼包皆可获得充值积分，比例为 1 : 1\r\n\r\n";
			txt += "\t#d当充值积分累积达到要求后可以领取对应的充值奖励噢~\r\n\r\n";
			txt += "\t当前累积的充值积分为：#r" + 充值积分 + "#k#l	\r\n\r\n";
			// txt += "#L1#" + JD + "领取#v1002850##z1002850# (充值积分达到50)\r\n\r\n";
			// txt += "#L2#" + JD + "领取#v1112919##z1112919##l\r\n\r\n\t#r四属性+3  攻击魔力+9#k  (充值积分达到100)\r\n\r\n";
			// txt += "#L3#" + JD + "强化#v1032024##z1032024##l\r\n\r\n\t#r四属性+30 攻击魔力+10#k (充值积分达到200)\r\n\r\n";
			// txt += "#L4#" + JD + "强化#v1022079##z1022079##l\r\n\r\n\t#r四属性+30 攻击魔力+10#k (充值积分达到300)\r\n\r\n";
			// txt += "#L5#" + JD + "强化#v1012057##z1012057##l\r\n\r\n\t#r四属性+30 攻击魔力+10#k (充值积分达到400)\r\n\r\n";
			//txt += "#L6#"+JD+"领取#v1003843##z1003843# (充值积分达到500)#l\r\n\r\n";
			var st="#r不能领取";
			for (var key in itemlist) {
				if(充值积分 >= itemlist[key][0] && cm.getPlayer().getBossLogS("赞助奖励" + (parseInt(key) + 1)) == 0) {
					st="#b可以领取";
				}else if(充值积分 < itemlist[key][0]){
					st="#r不能领取";
				}else{
					st="#d领取过了";
				}
				txt += "#L" + key + "#" + JD + "领取累充奖励（积分达到" + itemlist[key][0] + "）" +st + "#k#l\r\n\r\n";

			}
			txt += "  "
			cm.sendSimple("" + txt + "");
		} else if (status == 1) {
			seljl = selection;
			var add = "下面是你的奖励：\r\n\r\n";
			if (充值积分 >= itemlist[seljl][0] && cm.getPlayer().getBossLogS("赞助奖励" + (parseInt(seljl) + 1)) == 0) {
				for (var k = 1; k < itemlist[seljl].length; k++) {
					add += "#v" + itemlist[seljl][k][0] + "##z" + itemlist[seljl][k][0] + "# X "+itemlist[seljl][k][1]+"个#l\r\n";
				}
				cm.sendNext(add);
			} else {
				for (var k = 1; k < itemlist[seljl].length; k++) {
					add += "#v" + itemlist[seljl][k][0] + "##z" + itemlist[seljl][k][0] + "# X "+itemlist[seljl][k][1]+"个#l\r\n";
				}
				add += "#r上边看看就行了~#k#l";
				cm.sendOk(add);
				cm.dispose();
				return;
			}
		} else if (status == 2) {
			if (充值积分 >= itemlist[seljl][0] && cm.getPlayer().getBossLogS("赞助奖励" + (parseInt(seljl) + 1)) == 0) {
				for (var j = 1; j < itemlist[seljl].length; j++) {
					cm.gainItem(itemlist[seljl][j][0],itemlist[seljl][j][1]);
				}
				cm.setBossLog("赞助奖励"+(parseInt(seljl)+1));
				cm.sendOk("领取成功！");
			} else {
				cm.sendOk("条件不足！");

			}
			cm.dispose();
			return;
		}
	}
}

